package com.highper.admin.controller;

import cn.dev33.satoken.stp.StpUtil;
import com.highper.admin.service.IAdminUserService;
import com.highper.common.entity.po.admin.AdminUser;
import com.highper.common.entity.po.application.AppUser;
import com.highper.common.entity.response.HighperResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author ZhangGJ
 * @Date 2022/02/07 09:42
 */
@RestController
@RequestMapping("admin/user")
public class AdminUserController {

    private final IAdminUserService adminUserService;

    @Autowired
    public AdminUserController(IAdminUserService adminUserService) {
        this.adminUserService = adminUserService;
    }

    @GetMapping("list")
    public HighperResponse adminUserList() {
        AppUser appuser = (AppUser) StpUtil.getSession().get("user");
        return HighperResponse.data(adminUserService.list());
    }

    @PostMapping("insert")
    public HighperResponse insertAdminUser(@RequestBody AdminUser adminUser) {
        return HighperResponse.result(adminUserService.save(adminUser));
    }
}
